<?php
/**
 * +--------------------------------------------------------+
 * @Created by Phpstorm.
 * @Category MyStockService.php
 * @Depiction
 * @Author hwy <429208948@qq.com>
 * @Date 2022/4/24  16:55
 * +--------------------------------------------------------+
 */

namespace App\Services;

use App\Jobs\DataCapJob;
use App\Repositories\MyStockRepository;
use App\Repositories\StockPeaRepository;
use Carbon\Carbon;
use Illuminate\Support\Facades\Cache;

class MyStockService extends BaseService
{
    const STOCK_URL = 'http://qt.gtimg.cn/q=';

    protected $myStockRepository;

    protected $stockPeaRepository;

    public function __construct(MyStockRepository $myStockRepository, StockPeaRepository $stockPeaRepository)
    {
        $this->myStockRepository = $myStockRepository;

        $this->stockPeaRepository = $stockPeaRepository;
    }

    public function getList($params)
    {
        $list = $this->myStockRepository->getList($params);

        return $this->initPaginateData($list);
    }

    public function addData($params)
    {


    }


    public function getStocks($type)
    {
        if (is_array($type)) {
            $type = $type[0] ?? 1;
        }
        $data = $this->myStockRepository->getStocks($type);

        if ($data) {
            return $data->toArray();
        }

        return [];
    }

    public function addPeas($data)
    {
        return $this->stockPeaRepository->addData($data);
    }



}
